﻿using IServices;
using Models.DbModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace Services
{
    public class BindUserRoleServices:Repository<BindUserRole>,IBindUserRoleServices
    {

        public async Task<List<string>> GetRolesAsync(Guid userId) 
        {
            var list = await base.Context.Queryable<BindUserRole,Role>((ur,r)=> new JoinQueryInfos(
                JoinType.Left,ur.RoleId == r.Id))
                .Where(ur=>ur.UserId == userId)
                .Select((ur,r)=>r.Code)
                .ToListAsync();
            return list;
        }
    }
}
